﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Web.Corp
{
    public partial class corpview : System.Web.UI.Page
    {
        public Entity.CorpInfo corpObj = new Entity.CorpInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["cid"] == null)
                    Response.Redirect("~/index.aspx");
                else
                    BindDetail();
                BindSameCorp();
            }
        }
        protected void BindDetail()
        {
            corpObj = (new Controller.CorpInfoShow()).GetCorpViewDetail(Request["cid"].ToString());
        }
        public string GetVideUrl()
        {
            try
            {
                if (Request["vid"] != null)
                {
                    return (new Model.CorpVideoData()).GetVideoUrlByVideoID(Convert.ToInt32(Request["vid"]));
                }
                else if (Request["cid"] != null)
                {
                    return (new Model.CorpVideoData()).GetVideoUrlByCorpID(Convert.ToInt32(Request["cid"]));
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                throw;
            }
        }

        public void BindSameCorp()
        {

            DataSet dsSame = (new Model.CorpInfoData()).SoTopHot(5, corpObj.TypeID, corpObj.AreaID);
            rptSameCorp.DataSource = dsSame.Tables[0].DefaultView;
            rptSameCorp.DataBind();

            DataSet dsAround = (new Model.CorpInfoData()).SoTopHot(5, null, corpObj.AreaID);
            rptAroundCorp.DataSource = dsAround.Tables[0].DefaultView;
            rptAroundCorp.DataBind();

            rptAroundCorpTitle.DataSource = dsAround.Tables[0].DefaultView;
            rptAroundCorpTitle.DataBind();

            DataSet dsComment = (new Model.CorpCommentData()).SelectByCorpID(corpObj.CorpID);
            rptcmt.DataSource = dsComment.Tables[0].DefaultView;
            rptcmt.DataBind();
        }
    }
}
